﻿//********************************************************************************//
//创建日期：<创建日期，2017-08-29>
//创建作者：<郭登杰，guodengjie@shanghai3h.com>
//功能说明：自来水加价账单打印
//********************************************************************************//
layui.use(['layer', 'form',  'element','laydate', 'jquery'], function () {
    var layer = layui.layer
    , form = layui.form()
    , element = layui.element()
    , laydate = layui.laydate
    , $ = layui.jquery;

    /*initial load start*/
    initinfo();
    /*initial load end*/

    /*initial*/
    function initinfo() {
        //显示当前发票号码
        $("#lsBillNo").text(getFaPiaoHM(1));
        var date = new Date()
        //$("#c2PrintDate").val(date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate());
        //$("#c3PrintDate").val(date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate());
    }
    function getFaPiaoHM(count) {
        var fphms = "";
        //显示当前打印发票号码
        $.ajax({
            type: "post",
            cache: false,
            async: false,
            url: "/ashx/YSZW/FaPiao.ashx",
            data: {
                "op": "FiaoPiaoHMHQ",
                "count": count
            },
            dataType: "json",
            success: function (rs) {
                if (rs.State) {
                    fphms = rs.Data1;
                }
                else {
                    layer.alert(rs.Msg);
                }
            },
            error: function (error) {
                layer.msg(error.responseText);
            }
        });
        return fphms;
    }
    /*end initial*/

    /*event*/
    $("#oSearch").click(function () {
        if ($("#cYHH").val() == "") {
            layer.alert("请输入用户号");
            return;
        }
        if ($("#cY1").val() == "" || $("#cY2").val() == "") {
            layer.alert("请输入水量年区间");
            return;
        }
        load();
        bindOperate();
    });
    $("#oReset").click(function () {
        $("#cYHH").val("");
        $("#ContentList1 .datarow").remove();
        $("#lsCount").text("0");
        $("#lsMoney").text("0.00");
    });
    $("#o2Search").click(function () {
        var checkboxs = $("[name='c2Printed']:checked");
        if (checkboxs.length == 0) {
            layer.alert("至少选择一种打印状态");
            return;
        }
        var ym = $("#c2YM").val();
        //2种选中情况  1:已打印未打印均选中 查询全部用2表示  2:查询1种(1:已打印 0:未打印)
        var zt = (checkboxs.length == 2) ? 0 : (checkboxs.length == 1) ? $(checkboxs[0]).val() : -1;
        var hm = $("#c2HM").val();
        var printdate = $("#c2PrintDate").val();
        load2(zt, ym, hm, printdate);
    });
    $("#o2Clear").click(function () {
        chunk($("#ContentList2 .datarow"), list2Clear, null);
    });

    $("#o3Search").click(function () {
        var printdate = $("#c3PrintDate").val();
        load3(printdate);
    });
    $("#o3Clear").click(function () {
        $("#ContentList3 .datarow").remove();
        $("#ls3Count").text(0);
    });

    $("#o2Operate").click(function () {
        var checks = $("#ContentList2 .datarow").find("[name='liCheck']:checked");
        if (checks.length == 0) {
            layer.alert("请勾选要操作的项");
            return;
        }
        //获取选中发票号码
        var bhsArr = new Array();
        $(checks).each(function () {
            bhsArr.push($(this).attr("vid"));
        });
        var zdbhsArr = new Array();
        $(checks).each(function () {
            zdbhsArr.push($(this).attr("vid2"));
        });
        layer.alert("将选中发票打印状态变更为:", {
            btn: ['成功', '打坏', '未打印'],
            btn1: function (index) {
                //同一账单不能有两条以上成功打印记录
                for (var i = 0; i < zdbhsArr.length; i++) {
                    for (var j = 0; j < zdbhsArr.length; j++) {
                        if (i != j && zdbhsArr[i] == zdbhsArr[j]) {
                            layer.alert("同一账单不能有两条以上成功打印记录");
                            layer.close(index);
                            return;
                        }
                    }
                }
                $.ajax({
                    type: "post",
                    cache: false,
                    async: false,
                    url: "/ashx/YSSF/ZhangDan.ashx",
                    data: {
                        "op": "DYZTBG",
                        "dyzt": 1,
                        "fphms": bhsArr.join(",")
                    },
                    dataType: "json",
                    success: function (rs) {
                        if (rs.State) {
                            //更新打印状态显示
                            //未变更的排除
                            var bhsT = rs.Data1.split(",");
                            var exists = false;
                            for (var i = 0; i < bhsArr.length; i++) {
                                for (var j = 0; j < bhsT.length; j++) {
                                    if (bhsArr[i] == bhsT[j]) {
                                        exists = true;
                                        break;
                                    }
                                }
                                if (!exists) {
                                    var tr = $("#ContentList2 .datarow[vid='" + bhsArr[i] + "']");
                                    $(tr).find("td[name='litDYZT']").text("成功");
                                }
                            }
                            $("#lsBillNo").text(getFaPiaoHM(1));
                        }
                        layer.alert(rs.Msg);
                    },
                    error: function (error) {
                        layer.msg(error.responseText);
                    }
                });
                layer.close(index);
            },
            btn2: function (index) {
                $.ajax({
                    type: "post",
                    cache: false,
                    async: false,
                    url: "/ashx/YSSF/ZhangDan.ashx",
                    data: {
                        "op": "DYZTBG",
                        "dyzt": 2,
                        "fphms": bhsArr.join(",")
                    },
                    dataType: "json",
                    success: function (rs) {
                        if (rs.State) {
                            //更新打印状态显示
                            for (var i = 0; i < bhsArr.length; i++) {
                                var tr = $("#ContentList2 .datarow[vid='" + bhsArr[i] + "']");
                                $(tr).find("td[name='litDYZT']").text("打坏");
                            }
                            $("#lsBillNo").text(getFaPiaoHM(1));
                        }
                        else {
                            layer.alert(rs.Msg);
                        }
                    },
                    error: function (error) {
                        layer.msg(error.responseText);
                    }
                });
                layer.close(index);
            },
            btn3: function (index) {
                $.ajax({
                    type: "post",
                    cache: false,
                    async: false,
                    url: "/ashx/YSSF/ZhangDan.ashx",
                    data: {
                        "op": "DYZTBG",
                        "dyzt": 0,
                        "fphms": bhsArr.join(",")
                    },
                    dataType: "json",
                    success: function (rs) {
                        if (rs.State) {
                            //更新打印状态显示
                            for (var i = 0; i < bhsArr.length; i++) {
                                var tr = $("#ContentList2 .datarow[vid='" + bhsArr[i] + "']");
                                $(tr).remove();
                            }
                            $("#lsBillNo").text(getFaPiaoHM(1));
                        }
                        else {
                            layer.alert(rs.Msg);
                        }
                    },
                    error: function (error) {
                        layer.msg(error.responseText);
                    }
                });
                layer.close(index);
            }
        });

    });

    /*此页当前为单项打印,暂无需此功能
    //临听全选/取消
    form.on("checkbox(selectAll)", function (data) {
        if (data.elem.checked) {
            $("#ContentList1 .datarow:visible").find("[name='liCheck']").prop("checked", "checked");
        }
        else {
            $("#ContentList1 .datarow:visible").find("[name='liCheck']").removeProp("checked");
        }
        form.render("checkbox");
    });
    */
    //监听选择
    form.on('checkbox(liCheck)', function (data) {
        var vid = $(data.elem).attr("vid");
        $("input[lay-filter='liCheck']").each(function () {
            if ($(this).attr("vid") != vid) {
                $(this).removeProp("checked");
            }
        });
        form.render("checkbox");
        //重新计划选中数量及总金额
        var checks = $("input[lay-filter='liCheck']:checked");
        $("#lsCount").text(checks.length);
        var jine = 0;
        for (var i = 0; i < checks.length; i++) {
            jine = jine + parseFloat($(checks[i]).parent().nextAll().eq(3).text());
        }
        $("#lsMoney").text(jine.toFixed(2));
    });
    //监听发票号码手动输入开关
    form.on("switch(oBillInputSwitch)", function (data) {
        $("#ContentList1 .datarow:visible").each(function () {
            if (data.elem.checked) {
                $(this).find("[name='liFaPiaoHM']").show();
            }
            else {
                $(this).find("[name='liFaPiaoHM']").hide();
            }
        });
    });
    //临听全选/取消
    form.on("checkbox(selectAll2)", function (data) {
        if (data.elem.checked) {
            $("#ContentList2 .datarow:visible").find("[name='liCheck']").prop("checked", "checked");
        }
        else {
            $("#ContentList2 .datarow:visible").find("[name='liCheck']").removeProp("checked");
        }
        form.render("checkbox");
    });
    $("#btnPrint").click(function () {
        //判断是否有可用发票
        if ($("#lsBillNo").text() == "") {
            layer.alert("无可用发票");
            return;
        }
        //获取未打印的勾选 未打印:vid2=0 
        var checks = $("#ContentList1 .datarow[vid2='0']").find("input[lay-filter='liCheck']:checked");
        if (checks.length == 0) {
            layer.alert("请勾选要打印的账单");
            return;
        }
        var sffs = $("#oiSFFS").val();
        if (sffs<=0) {
            layer.alert("请选择收费方式");
            return;
        }
        var khhm = "";
        //要打印的账单资料完整度验证
        $(checks).each(function () {
            //debugger;
            khhm = $(this).parent().parent().find("input[name='liKHHM']").val();
            if (khhm == "") {
                layer.alert("请完善开户户名");
                return;
            }
        });
        var logicOK = true;
        //如果开启了发票号码手动输入
        var fphmsArr = new Array();
        var t = "";
        if ($("#oBillInputSwitch").prop("checked")) {
            $(checks).each(function () {
                t = $("#ContentList1 .datarow[vid='" + $(this).attr("vid") + "']").find("[name='liFaPiaoHM']").val();
                if (t == "") {
                    layer.alert("您选择了手动输入发票号码,请将勾选项的发票号码填写完整.");
                    logicOK = false;
                    return false;
                }
                else {
                    fphmsArr.push(t);
                }
            });
            if (!logicOK) return;
        }
        else {
            //未开启手动输入,获取需要打印账单数量对应的发票号码
            //var fphms = getFaPiaoHM($(checks).length);
            var fphms = $("#lsBillNo").text();
            fphmsArr = fphms.split(",");
        }
        var fphm = fphmsArr.join(",");
        //取得报表参数 
        var tr = $(checks[0]).parent().parent();
        var zdbh=$(tr).attr("vid");
        var yhh = $(tr).find("td[name='litYHH']").text();
        var yhm = $(tr).find("input[name='liYHM']").val();
        var ym = $(tr).find("td[name='litYM']").text();
        var khhm = $(tr).find("input[name='liKHHM']").val();
        var jhl=$(tr).find("td[name='litJHL']").text();
        var syl=$(tr).find("td[name='litSYL']").text();
        var jjl=$(tr).find("td[name='litJJL']").text();
        var jjje=$(tr).find("td[name='litJJJE']").text();
        var params = new Array();
        params.push("V_SHOUFEIFS:" + sffs);
        params.push("V_FAPIAOHM:" + fphm);
        params.push("V_FEIYONGBH:" + zdbh);
        params.push("V_YONGHUH:" +yhh );
        params.push("V_YONGHUM:" + escape(yhm));
        params.push("V_YM:" + ym);
        params.push("V_KAIHUM:" + escape(khhm));
        params.push("V_JHL:" + jhl);
        params.push("V_SYL:" +syl );
        params.push("V_JJL:" + jjl);
        params.push("V_JJJE:" + jjje);
        //alert(zdbh + "," + yhm + "," + khhm + "," + fphm);
        wap.common.printjx('ZhangDanDY', [
            { key: 'QUERYPARAM', value: params.join("|") },
            { key: 'BAOBIAOID', value: 100201 },
            { key: 'USERINFO', value: "csms" }
        ]);
        var dyjg = "";
        layer.alert("请确认打印状态!", {
            closeBtn: false,
            btn: ['成功', '打坏', '未打印'],
            btn1: function (index) {
                $.ajax({
                    type: "post",
                    cache: false,
                    async: false,
                    url: "/ashx/YSSF/ZhangDan.ashx",
                    data: {
                        "op": "DY",
                        "dyzt": "success",
                        "sffs":sffs,
                        "zdbh": zdbh,
                        "yhh": yhh,
                        "yhm": yhm,
                        "khhm": khhm,
                        "fphm": fphm
                    },
                    dataType: "json",
                    success: function (rs) {
                        if (rs.State) {
                            //更新行打印状态记录值
                            var trNow = $("#ContentList1 tr[vid='" + zdbh + "']");
                            $(trNow).attr("vid2", "1");
                            ////为当前打印的账单更新上发票号码
                            //$("#ContentList1 tr[vid='" + zdbh + "']").find("td").eq(11).text(fphm);
                            ////更新打印状态显示
                            //$("#ContentList1 tr[vid='" + zdbh + "']").find("td").eq(12).html("<i class=\"layui-icon\" style=\"font-size: 15px; color: #1E9FFF;cursor: pointer;\">&#xe605;</i>");
                            SetPrintedInfo(trNow,fphm);
                            //重新加载下一张发票号码
                            initinfo();
                        }
                        else {
                            layer.alert(rs.Msg);
                        }
                    },
                    error: function (error) {
                        layer.msg(error.responseText);
                    }
                });
                layer.close(index);
            },
            btn2: function (index) {
                $.ajax({
                    type: "post",
                    cache: false,
                    async: false,
                    url: "/ashx/YSSF/ZhangDan.ashx",
                    data: {
                        "op": "DY",
                        "dyzt": "broken",
                        "sffs": sffs,
                        "zdbh": zdbh,
                        "yhh": yhh,
                        "yhm": yhm,
                        "khhm": khhm,
                        "fphm": fphm
                    },
                    dataType: "json",
                    success: function (rs) {
                        if (rs.State) {
                        //重新加载下一张发票号码
                            initinfo();
                        }
                        else {
                            layer.alert(rs.Msg);
                        }
                    },
                    error: function (error) {
                        layer.msg(error.responseText);
                    }
                });
                layer.close(index);
            },
            btn3: function (index) {

            }
        });
    });

    $("#btnPrintSaving").click(function () {
        //获取已打印的勾选 已打印:vid2=1
        var checks = $("#ContentList1 .datarow[vid2='1']").find("input[lay-filter='liCheck']:checked");
        if (checks.length == 0)
        {
            checks = $("#ContentList1 .datarow[vid2='0']").find("input[lay-filter='liCheck']:checked");
            if (checks.length > 0)
                layer.alert("未打印的费用暂无对应的发票号码，不能打印存根。");
            else
                layer.alert("请勾选要打印存根的账单");
            return;
        }
        if (checks.length > 1) {
            layer.alert("请选择单条打印");
            return;
        }
        //检查用户名与开户名
        var zdbhs = new Array();
        var yhms = new Array();
        var valTemp = "";
        var row = $("#ContentList1 .datarow[vid='" + $(checks).eq(0).attr("vid") + "']");
        var yhm=row.find("input[name='liYHM']").val();
        if (yhm == "") {
            layer.alert("请完善用户名");
            return;
        }
        zdbhs.push($(checks).eq(0).attr("vid"));
        
        //制作报表参数 
        var params = new Array();
        params[0] = "V_FEIYONGBHS:" + zdbhs.join(",");
        params[1] = escape("V_YHM:" + yhm);
        wap.common.printjx('ZhangDanDY', [
            { key: 'QUERYPARAM', value: params.join("|") },
            { key: 'BAOBIAOID', value: 120002 },
            { key: 'USERINFO', value: "csms" }
        ]);
    });
    /*event end*/

    /*list*/
    function createItemStr(obj) {
        var str = $("#ItemStr1 tr").prop("outerHTML");
        var itemstr, dyzt, id, yhh, yhm, ym, jine,jhl,syl,jjl, khhm, khyh, khzh, fphm;
        dyzt = obj["I_ZHUANGTAI"]["Value"];
        id = obj["I_FEIYONGBH"]["Value"];
        yhh = obj["S_YONGHUH"];
        yhm = obj["S_YONGHUM"];
        ym = obj["I_YM"]["Value"];
        jine = obj["N_JJJE"]["Value"];
        jhl = obj["I_JHL"]["ValueString"];
        syl = obj["I_SYL"]["ValueString"];
        jjl = obj["I_JJL"]["ValueString"];
        khhm = obj["S_KAIHUHM"];
        khyh = obj["S_KAIHUYH"]
        khzh = obj["S_KAIHUZH"];
        fphm = obj["S_FAPIAOHM"];
        itemstr = str.replace(new RegExp("objDYZT", "gm"), dyzt).replace(new RegExp("objid", "gm"), id).replace(new RegExp("objYHH", "gm"), yhh)
                        .replace(new RegExp("objYHM", "gm"), yhm).replace(new RegExp("objYM", "gm"), ym)
                        .replace(new RegExp("objJinE", "gm"), jine.toFixed(2))
                        .replace(new RegExp("objJiHuaL", "gm"), jhl)
                        .replace(new RegExp("objShiYongL", "gm"), syl)
                        .replace(new RegExp("objJiaJiaL", "gm"), jjl)
                        .replace(new RegExp("objKHHM", "gm"), khhm)
                        .replace(new RegExp("objFPHM", "gm"), fphm)
        ;
        return itemstr;
    }
    function load() {
        var index = layer.load(1);
        $.ajax({
            type: "post",
            cache: false,
            async: false,
            url: "/ashx/YSSF/ZhangDan.ashx",
            data: {
                "op": "ZDXX",
                "type": $("input[name='cType']:checked").val(),
                "sffs":$("#oiSFFS").val(),
                "yhh": $("#cYHH").val(),
                "y1": $("#cY1").val(),
                "y2": $("#cY2").val()
            },
            dataType: "json",
            success: function (rs) {
                var strs = "";
                for (var i in rs) {
                    strs = strs + createItemStr(rs[i]);
                }
                $("#ContentList1").find(".datarow").remove();
                $("#ContentList1").append(strs);
                form.render("checkbox");
                //默认完善开户名信息(无开户户名,默认填写用户名)
                var trs = $("#ContentList1 .datarow");
                for (var i = 0; i < trs.length; i++) {
                    if ($(trs[i]).find("input[name='liKHHM']").val() == "") {
                        $(trs[i]).find("input[name='liKHHM']").val($(trs[i]).find("input[name='liYHM']").val());
                    }
                }
                //设置打印状态显示
                $("#ContentList1 .datarow").each(function () {
                    if ($(this).attr("vid2") == "1") {
                        SetPrintedInfo($(this),"");
                        ////用户名与开户名,发票号码去除输入框
                        //var mcinput = $(this).find("input[name='liYHM']");
                        //mcinput.parent().text(mcinput.val());
                        //mcinput = $(this).find("input[name='liKHHM']");
                        //mcinput.parent().text(mcinput.val());
                        //mcinput = $(this).find("input[name='liFaPiaoHM']");
                        //mcinput.parent().text(mcinput.val());
                        //$(this).find("td").eq(11).html("<i class=\"layui-icon\" style=\"font-size: 15px; color: #1E9FFF;cursor: pointer;\">&#xe605;</i>");
                    }
                });
            },
            error: function (error) {
                layer.msg(error.responseText);
            }
        });
        layer.close(index);
    }
    //设置打印后信息(用户名,开户名,发票等)
    function SetPrintedInfo(obj,fphm)
    {
        //用户名与开户名,发票号码去除输入框
        /*
        var mcinput = $(obj).find("input[name='liYHM']");
        $(obj).find("td[name='litYHM']").text(mcinput.val());
        mcinput = $(obj).find("input[name='liKHHM']");
        $(obj).find("td[name='litKHHM']").text(mcinput.val());
        */
        var mcinput = $(obj).find("input[name='liKHHM']");
        $(obj).find("td[name='litKHHM']").text(mcinput.val());
        if (fphm != "") {
            $(obj).find("td[name='litFPHM']").text(fphm);
        }
        else {
            mcinput = $(obj).find("input[name='liFaPiaoHM']");
            $(obj).find("td[name='litFPHM']").text(mcinput.val());
        }
        $(obj).find("td[name='litDYZT']").html("<i class=\"layui-icon\" style=\"font-size: 15px; color: #1E9FFF;cursor: pointer;\">&#xe605;</i>");
    }
    function bindOperate() {
        //开户名与用户名同步变动
        $("#ContentList1 .datarow").find("input[name='liYHM']").blur(function () {
            $(this).parent().parent().find("input[name='liKHHM']").val($(this).val());
        });
        //设置补打和打印启禁用
        if ($("input[name='cType']:checked").val() == "0") {
            //$("#btnPrintSaving").attr("disabled", "disabled");
            $("#btnPrint").removeAttr("disabled");
            //$("#btnPrintSaving").css("cursor", "default");
            $("#btnPrint").css("cursor", "pointer");
        }
        else {
            $("#btnPrintSaving").removeAttr("disabled");
            $("#btnPrint").attr("disabled", "disabled");
            $("#btnPrintSaving").css("cursor", "pointer");
            $("#btnPrint").css("cursor", "default");
        }
        /*
        //行点击切换选中状态
        $("#ContentList1 .datarow").each(function () {            
            var cb = $(this).find("[name='liCheck']");
            $(this).find("[name='liCheck']").removeProp("checked");
            $(this).find("td").unbind("click").click(function () {
                var checked = $(cb).prop("checked");
                $("#ContentList1 .datarow").find("[name='liCheck']").removeProp("checked");
                if (checked) {
                    $(cb).removeProp("checked");
                }
                else {
                    $(cb).prop("checked", "checked");
                }
                form.render("checkbox");
            });
            //移除选择列与发票号码列click事件
            $("#ContentList1 .datarow").each(function () {                
                $(this).find("td").eq(0).unbind("click");
                if ($(this).attr("vid2") != "1") {
                    $(this).find("td[name='litYHM']").unbind("click");
                    $(this).find("td[name='litKHHM']").unbind("click");
                    $(this).find("td[name='litFPHM']").unbind("click");
                }
            });
        });
        */
    }

    function load2(zt, ym, hm, printdate) {
        var rss = "";
        $.ajax({
            type: "post",
            cache: false,
            async: false,
            url: "/ashx/YSSF/ZhangDan.ashx",
            data: {
                "op": "YDLIST",
                "zt": zt,
                "ym": ym == "" ? 0 : ym,
                "hm": hm,
                "printdate": printdate
            },
            dataType: "json",
            success: function (rs) {
                rss = rs;
            },
            error: function (error) {
                layer.msg(error.responseText);
            }
        });
        var strs = "";
        $("#ls2Count").text(rss.length);
        $("#ContentList2").find(".datarow").remove();
        if (rss.length > 0) {
            chunk(rss, list2Create, bindListOperat2);
        }
    }
    function list2Create(rs, i) {
        $("#ContentList2").append(createItemStr2(rs));
        $("#ls2Count").text($("#ContentList2 .datarow").length);
    }
    function list2Clear(rs, i) {
        $(rs).remove();
        $("#ls2Count").text($("#ContentList2 .datarow").length);
    }
    function createItemStr2(obj) {
        var str = $("#ItemStr2 tr").prop("outerHTML");
        var itemstr, zdbh, yhh, yhm, jine, jhl, syl, jjl, sj, sl, ym, dyrq, dyzt, fphm;
        zdbh = obj["I_FEIYONGBH"]["Value"];
        yhh = obj["S_YONGHUH"];
        yhm = obj["S_YONGHUM"];
        jine = obj["N_JJJE"]["Value"];
        jhl = obj["I_JHL"]["ValueString"];
        syl = obj["I_SYL"]["ValueString"];
        jjl = obj["I_JJL"]["ValueString"];
        ym = obj["I_YM"]["ValueString"];
        dyrq = obj["D_DAYINRQ"]["DateString"];
        dyzt = obj["I_ZHUANGTAI"]["Value"] == "1" ? "成功" : obj["I_ZHUANGTAI"]["Value"] == "2" ? "打坏" : "未知";
        fphm = obj["S_FAPIAOHM"]
        itemstr = str.replace(new RegExp("objZhangDanBH", "gm"), zdbh)
                        .replace(new RegExp("objYongHuH", "gm"), yhh)
                        .replace(new RegExp("objYongHuM", "gm"), yhm)
                        .replace(new RegExp("objJinE", "gm"), jine.toFixed(2))
                        .replace(new RegExp("objJiHuaL", "gm"), jhl)
                        .replace(new RegExp("objShiYongL", "gm"), syl)
                        .replace(new RegExp("objJiaJiaL", "gm"), jjl)
                        .replace(new RegExp("objShuiLiang", "gm"), sl)
                        .replace(new RegExp("objYM", "gm"), ym)
                        .replace(new RegExp("objDaYinRQ", "gm"), dyrq)
                        .replace(new RegExp("objDaYinZT", "gm"), dyzt)
                        .replace(new RegExp("objFaPiaoHM", "gm"), fphm)
        ;
        return itemstr;
    }
    function bindListOperat2() {
        //行点击切换选中状态
        $("#ContentList2 .datarow").each(function () {
            var cb = $(this).find("[name='liCheck']");
            $(this).find("td").unbind("click").click(function () {
                if ($(cb).prop("checked")) {
                    $(cb).removeProp("checked");
                }
                else {
                    $(cb).prop("checked", "checked");
                }
                form.render("checkbox");
            });
            //移除选择列click事件
            $("#ContentList2 .datarow").each(function () {
                $(this).find("td").eq(0).unbind("click");
            });

        });
    }

    function load3(printdate) {
        var index = layer.load(1);
        $.ajax({
            type: "post",
            cache: false,
            async: false,
            url: "/ashx/YSSF/ZhangDan.ashx",
            data: {
                "op": "DYTJ",
                "printdate": printdate
            },
            dataType: "json",
            success: function (rs) {
                var strs = "";
                for (var i in rs) {
                    strs = strs + createItemStr3(rs[i]);
                }
                $("#ls3Count").text(rs.length);
                $("#ContentList3").find(".datarow").remove();
                $("#ContentList3").append(strs);
            },
            error: function (error) {
                layer.msg(error.responseText);
            }
        });
        layer.close(index);
    }
    function createItemStr3(obj) {
        var str = $("#ItemStr3 tr").prop("outerHTML");
        var itemstr, qshm, jshm, sl, dyrq;
        qshm = obj["S_QISHIFPHM"];
        jshm = obj["S_JIESHUFPHM"];
        sl = obj["I_SL"];
        dyrq = obj["D_DAYINRQ"]["DateString"];
        itemstr = str.replace(new RegExp("objQISHIFPHM", "gm"), qshm)
                        .replace(new RegExp("objJIESHUFPHM", "gm"), jshm)
                        .replace(new RegExp("objSL", "gm"), sl)
                        .replace(new RegExp("objDaYinRQ", "gm"), dyrq)
        ;
        return itemstr;
    }
    /*end list*/

    /*logic*/
    function verify() {
        return true;
    }

    /*logic end*/

   // exports('DaYinZD', {}); //注意，这里是模块输出的核心，模块名必须和use时的模块名一致
});